<a href='http://github.com/angular/angular.js/edit/master/src/ng/interpolate.js' class='improve-docs btn btn-primary'><i class="glyphicon glyphicon-edit">&nbsp;</i>Improve this doc</a>



<a href='http://github.com/angular/angular.js/tree/master/src/ng/interpolate.js#L86' class='view-source pull-right btn btn-primary'>
  <i class="glyphicon glyphicon-zoom-in">&nbsp;</i>View Source
</a>


<header class="api-profile-header">
  <h1 class="api-profile-header-heading">$interpolate</h1>
  <ol class="api-profile-header-structure naked-list step-list">
    
  <li>
    <a href="api/ng/provider/$interpolateProvider">- $interpolateProvider</a>
  </li>

    <li>
      - service in module <a href="api/ng">ng</a>
    </li>
  </ol>
</header>



<div class="api-profile-description">
  <p>Compiles a string with markup into an interpolation function. This service is used by the
HTML <a href="api/ng/service/$compile">$compile</a> service for data binding. See
<a href="api/ng/provider/$interpolateProvider">$interpolateProvider</a> for configuring the
interpolation markup.</p>
<pre><code class="lang-js">  var $interpolate = ...; // injected
  var exp = $interpolate(&#39;Hello {{name | uppercase}}!&#39;);
  expect(exp({name:&#39;Angular&#39;}).toEqual(&#39;Hello ANGULAR!&#39;);</code></pre>

</div>




<div>
  
  <h2 id="dependencies">Dependencies</h2>
  <ul>
    <li><a href="api/ng/service/$parse"><code>$parse</code></a></li><li><a href="api/ng/service/$sce"><code>$sce</code></a></li>
  </ul>
  

    

  <h2 id="usage">Usage</h2>
    
      <p><code>$interpolate(text, [mustHaveExpression], [trustedContext]);</code></p>


    

    
<section class="api-section">
  <h3>Arguments</h3>

<table class="variables-matrix input-arguments">
  <thead>
    <tr>
      <th>Param</th>
      <th>Type</th>
      <th>Details</th>
    </tr>
  </thead>
  <tbody>
    
    <tr>
      <td>
        text
        
        
      </td>
      <td>
        <a href="" class="label type-hint type-hint-string">string</a>
      </td>
      <td>
        <p>The text with markup to interpolate.</p>

        
      </td>
    </tr>
    
    <tr>
      <td>
        mustHaveExpression
        
        <div><em>(optional)</em></div>
      </td>
      <td>
        <a href="" class="label type-hint type-hint-boolean">boolean</a>
      </td>
      <td>
        <p>if set to true then the interpolation string must have
   embedded expression in order to return an interpolation function. Strings with no
   embedded expression will return null for the interpolation function.</p>

        
      </td>
    </tr>
    
    <tr>
      <td>
        trustedContext
        
        <div><em>(optional)</em></div>
      </td>
      <td>
        <a href="" class="label type-hint type-hint-string">string</a>
      </td>
      <td>
        <p>when provided, the returned function passes the interpolated
   result through <a href="api/ng/service/$sce#getTrusted">$sce.getTrusted(interpolatedResult,
   trustedContext)</a> before returning it.  Refer to the <a href="api/ng/service/$sce">$sce</a> service that
   provides Strict Contextual Escaping for details.</p>

        
      </td>
    </tr>
    
  </tbody>
</table>

</section>
    
    <h3>Returns</h3>
<table class="variables-matrix return-arguments">
  <tr>
    <td><a href="" class="label type-hint type-hint-function">function(context)</a></td>
    <td><p>an interpolation function which is used to compute the
   interpolated string. The function has these parameters:</p>
<ul>
<li><code>context</code>: an object against which any expressions embedded in the strings are evaluated
against.</li>
</ul>
</td>
  </tr>
</table>

  
<h2>Methods</h2>
<ul class="methods">
  <li id="startSymbol">
    <h3><p><code>startSymbol();</code></p>

</h3>
    <div><p>Symbol to denote the start of expression in the interpolated string. Defaults to <code>{{</code>.</p>
<p>Use <a href="api/ng/provider/$interpolateProvider#startSymbol">$interpolateProvider#startSymbol</a> to change
the symbol.</p>
</div>

    

    
    
    
    <h4>Returns</h4>
    <table class="variables-matrix return-arguments">
  <tr>
    <td><a href="" class="label type-hint type-hint-string">string</a></td>
    <td><p>start symbol.</p>
</td>
  </tr>
</table>
    

  </li>
  
  <li id="endSymbol">
    <h3><p><code>endSymbol();</code></p>

</h3>
    <div><p>Symbol to denote the end of expression in the interpolated string. Defaults to <code>}}</code>.</p>
<p>Use <a href="api/ng/provider/$interpolateProvider#endSymbol">$interpolateProvider#endSymbol</a> to change
the symbol.</p>
</div>

    

    
    
    
    <h4>Returns</h4>
    <table class="variables-matrix return-arguments">
  <tr>
    <td><a href="" class="label type-hint type-hint-string">string</a></td>
    <td><p>end symbol.</p>
</td>
  </tr>
</table>
    

  </li>
  </ul>
  
  



  
</div>


